package live.jialing.sip.base.domain;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.google.common.collect.Lists;
import live.jialing.structure.domain.User;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.List;

/**
 * 孩子
 */
@Setter
@Getter
@ToString
@Entity
@DiscriminatorValue("child")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id",scope = Child.class)
public class Child extends User {

    // 家长
    @ManyToMany(mappedBy = "children", fetch = FetchType.LAZY)
    private List<Parent> parents = Lists.newArrayList();

    // 学生
    @OneToMany(mappedBy = "child",fetch = FetchType.LAZY)
    private List<Student> students = Lists.newArrayList();

}
